Skip to main content

merge join

Short Description

A merge join is preferred over a hash join and is chosen for equality queries when supporting indexes are available

Detailed Description​

A merge join is preferred over a hash join and is chosen for equality queries when supporting indexes are available. The sort order (ascending or descending) of indexes used must match.

MERGE JOINs are only available with distributed query processing.

CockroachDB processes a merge join as follows:

  • If the rows match, CockroachDB returns them.
  • If there are multiple matches, CockroachDB returns a cartesian product of the matches.
  • If the rows are not equal
    • For inner joins, CockroachDB discards the lower value and repeats the process with the next row.
    • For outer joins, CockroachDB returns NULL for the non-matching column and repeats the process with the next row until all rows are processed.

Search online​

If this article doesn't have the information you need you can try searching online. Remember, you can contribute suggestions to this page.